﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    using System.Data;

    public class DongiathuocBLL : DAL.DongiathuocDAL
    {   
        private string AddID(string id)
        {
            string s = id.Trim(); // bn01

            int len = s.Length; 
            string con = s.Substring(2); // 01
            string kq = s.Substring(0,2); // bn
            int so = Convert.ToInt32(con) + 1;
            if (so <= 9)
                kq += '0';
            kq += so;

            return kq;
        }

        public string CreateID()
        {
           // string result = Select_max().Trim();

            string result = "";
            DataTable dtb = Select_max();
            if (result.Length > 2)
            {
                result = result.Substring(2);
            }
            else result = "";

            int i =0;
            int.TryParse(result,out i);
            i++;

            
            return "BN" +i.ToString("0##");
           
        }

    }
}
